package main

import (
	"google.golang.org/grpc/credentials"
	"grpc-2/pb/services"
	"log"
	"net"

	"google.golang.org/grpc"
)

func main() {

	/*rpcServer := grpc.NewServer()
	services.RegisterProductServiceServer(rpcServer, new(services.ProdService))
	listen, err := net.Listen("tcp", ":8081")
	if err != nil {
		log.Fatalf("启动网络监听失败 %v\n", err)
	}
	rpcServer.Serve(listen)*/

	//单向ssl(服务端)验证, tcp-ip服务
	creds, err := credentials.NewServerTLSFromFile("D:\\code\\go\\go-learn\\grpc-ts\\grpc-2\\keys\\server.crt",
		"D:\\code\\go\\go-learn\\grpc-ts\\grpc-2\\keys\\server_no_password.key")
	if err != nil {
		log.Fatal(err)
	}

	rpcServer := grpc.NewServer(grpc.Creds(creds))
	services.RegisterProductServiceServer(rpcServer, new(services.ProdService))
	listen, err := net.Listen("tcp", ":8081")
	if err != nil {
		log.Fatalf("启动网络监听失败 %v\n", err)
	}
	rpcServer.Serve(listen)

}
